<template>
  <div>
    <a-table
      rowKey="id"
      class="wearing-table"
      :columns="callLogColumns"
      :dataSource="dataSource"
      @change="handleTableChange"
    >
      <template slot="action" slot-scope="records">
        <span class="operation deatil-color" @click="handleDelete(records)">删除</span>
      </template>
    </a-table>
    <all-message ref="allMessage" :title="confirmTitle" :content="confirmContent" @confirm="handleDelete"></all-message>
  </div>
</template>

<script>
import { JeecgListMixinNew } from '@/mixins/JeecgListMixinNew'
import allMessage from '@/components/allMessage'

export default {
  mixins: [JeecgListMixinNew],
  components: {
    allMessage,
  },
  data() {
    return {
      url: {
        list: '/wb/device/deviceEventPage',
      },
      callLogColumns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '预警类型',
          align: 'center',
          dataIndex: 'type',
          ellipsis: true,
          customRender: function (t, r, index) {
            const typeMap = {
              1: 'SOS',
              4: '电子围栏触发',
              8: '运动心率异常',
            }
            return typeMap[t] ? typeMap[t] : ''
          },
        },
        {
          title: '预警时间',
          align: 'center',
          dataIndex: 'eventTime',
          ellipsis: true,
        },
        {
          title: '地点',
          align: 'center',
          dataIndex: 'address',
          ellipsis: true,
        },
        {
          title: '处置情况',
          align: 'center',
          dataIndex: 'handlingSituation',
          ellipsis: true,
          customRender: function (t, r, index) {
            if (t) {
              return t
            } else {
              return '-'
            }
          },
        },
        {
          title: '处置人',
          align: 'center',
          dataIndex: 'helpId',
          ellipsis: true,
        },
        {
          title: '处置时间',
          align: 'center',
          dataIndex: 'updateTime',
          ellipsis: true,
        },
      ],
      disableMixinCreated: true,
      confirmTitle: '',
      confirmContent: '',
      publicVisible: false,
    }
  },
  mounted() {
    this.extendParams = {
      mentalPatientPersonId: this.$route.query.id,
    }
    // this.loadData(1)
  },
  method: {
    handleDelete(records) {
      this.confirmTitle = '删除'
      this.confirmContent = '请确认是否删除？'
      this.publicVisible = true
      this.$refs.allMessage.show(records)
    },
  },
}
</script>
